package com.ie.controller.admin;

import com.ie.common.http.ResponseResult;
import com.ie.common.sercurity.anno.AuthIgrone;
import com.ie.entity.GoodsTypeEntity;
import com.ie.service.admin.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @classname: GoodsTypeController
 * @Author: S2
 * @Description: //TODO
 * @Date: 2024/9/10  11:13
 * @Param:
 * @version: 1.0
 **/
@RestController
@RequestMapping("/api/admin/type")
public class GoodsTypeController {
    @Autowired
    private GoodsTypeService goodsTypeService;

    /**
     * @Description: //TODO
     * @Author: S2
     * @Date: 2024/9/10  11:14
     * @Param: []
     * @version: 1.0
     * @Return: com.ie.common.http.ResponseResult<java.util.List < com.ie.entity.GoodsTypeEntity>>
     **/
    @AuthIgrone //因为before的导航页需要查询商品类型
    @PostMapping("/getAllGoodsType")
    public ResponseResult<List<GoodsTypeEntity>> getAllGoodsType() {
        return ResponseResult.getSuccessResult(goodsTypeService.list());
    }
    @PostMapping("/getGoodsType")
    public ResponseResult<Map<String, Object>> getGoodsType(@RequestBody GoodsTypeEntity goodsTypeEntity){
        return goodsTypeService.getGoodsType(goodsTypeEntity);
    }
    @PostMapping("/add")
    public ResponseResult<Map<String, Object>> add(@RequestBody GoodsTypeEntity goodsTypeEntity) {
        return goodsTypeService.add(goodsTypeEntity);
    }

    @PostMapping("/update")
    public ResponseResult<Map<String, Object>> update(@RequestBody GoodsTypeEntity goodsTypeEntity) {
        return goodsTypeService.update(goodsTypeEntity);
    }

    @PostMapping("/delete")
    public ResponseResult<Map<String, Object>> delete(@RequestBody GoodsTypeEntity goodsTypeEntity) {
        return goodsTypeService.delete(goodsTypeEntity);
    }


}
